package vnreal.resources;

import vnreal.ExchangeParameter;
import vnreal.constraints.AbstractConstraint;
import vnreal.constraints.ILinkConstraint;
import vnreal.demands.AbstractDemand;
import vnreal.demands.DemandVisitorAdapter;
import vnreal.network.Link;
import vnreal.network.NetworkEntity;

public final class TypeOfLink extends AbstractResource implements ILinkConstraint {
	private String type;

	// Copper,Fiber

	public TypeOfLink(Link<? extends AbstractConstraint> owner) {
		super(owner);
	}

	@ExchangeParameter
	public void setType(String type) {
		this.type = type;
	}

	@ExchangeParameter
	public String getType() {
		return this.type;
	}

	@Override
	public boolean accepts(AbstractDemand dem) {
		return dem.getAcceptsVisitor().visit(this);
	}

	@Override
	public boolean fulfills(AbstractDemand dem) {
		return dem.getFulfillsVisitor().visit(this);
	}

	@Override
	protected DemandVisitorAdapter createOccupyVisitor() {
		return null;
	}

	@Override
	protected DemandVisitorAdapter createFreeVisitor() {
		return null;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Type = ");
		sb.append(getType());
		return sb.toString();
	}

	@Override
	public AbstractResource getCopy(NetworkEntity<? extends AbstractConstraint> owner) {

		TypeOfLink clone = new TypeOfLink((Link<? extends AbstractConstraint>) owner);
		clone.type = type;

		return clone;
	}

}
